All Functions Used So Far, Week 8

ifelse

{base}

Return a or b depending on the value of test

arrange

{dplyr}

Sort values of data frame according to a variable/combination of varaibles

as.numeric

{base}

Coerce a vector to numeric

ordered

{dplyr}

Create an ordered factor

read_dta

{haven}

Read a .dta file (Stata data)

write_dta

NA

select

{dplyr}

Select columns from a tibble/data frame

aes

{GGPLOT2}

Construct aesthetic mapping of a ggplot graph

labs

{GGPLOT2}

Customise labels in GGPLOT2

names

{base}

Retrieve names of a list/vector

save

{base}

Writes an external representation of R objects to the specified file.

ggplot

{GGPLOT2}

Create a ggplot graph

library

{base}

Load an R package

var

{stats}

Calculate variance

boxplot

{graphics}

Plot a simple box plot

filter

{dplyr}

Filter out rows of a data frame according to logical vector

head

{utils}

Show first 5 rows of a data frame

range

{base}

Return range of values

geom_histogram

{GGPLOT2}

Generates a histogram

is.na

{base}

Check if a value is NA/elements of vector are NA

scale_x_continuous

{GGPLOT2}

Customise continuous x axis

group_by

{dplyr}

Group tibble/data.frame by a factor variable. All further tidyverse operations are performed group-wise

theme_classic

{GGPLOT2}

A minimalistic theme with no gridlines

data.frame

{base}

Create a data.frame from vectors

summarise

{dplyr}

collapse the dataset to a summary statistic. Usually used with group_by()

write.csv

{utils}

write a csv file to a data frame

desc

{dplyr}

Arrange in descending order

sum

{base}

Get sum of numeric values or a vector

min

{base}

Get minimum of a vector

max

{base}

Get maximum of a vector

c

{base}

Combine values/vectors into a vector

as.character

{base}

Coerce a vector to character

mean

{base}

Get mean of a vector

summarize

NA

median

{stats}

Get median of a vector

table

{base}

Obtain frequency table of a variable/cross-tabulation of two variables

cut

{base}

Convert Numeric to Factor

sd

{stats}

Get standard deviation of a vector

n

{dplyr}

The number of observations in the current group.

hist

{graphics}

Plot a simple histogram

recode

{dplyr}

Recode a variable

seq

{base}

Create a sequence

separate

{dplyr}

Separate a character column into multiple columns

setwd

{base}

Set Working Directory

ungroup

{dplyr}

Resolve grouping created with “group_by”

slice

{dplyr}

Subset rows using their positions

read_excel

{readxl}

Read an Excel file

summary

{base}

Obtain summary statistics or detailed regression output

spread

{tidyr}

Spread a key-value pair across multiple columns

levels

{base}

Get levels of a factor

mutate

{dplyr}

Modify/create a column in a data frame

factor

{base}

Create a factor

str

{utils}

Get the structure of an R object

The end!